package com.cpr.core.bio;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.nio.charset.StandardCharsets;

/**
 * @author Chen Panrui
 * created at 2021/12/24 18:08
 */
public class BioClient {

    public static void main(String[] args) throws IOException {
        Socket socket = new Socket("127.0.0.1",9999);

        OutputStream output = socket.getOutputStream();
        output.write("还钱".getBytes(StandardCharsets.UTF_8));

        InputStream input = socket.getInputStream();
        byte[] bytes = new byte[1024];
        int read = input.read(bytes);
        System.out.println("服务端返回:" + new String(bytes, 0, read));

        socket.close();
    }
}
